﻿add_requires("opencv 4.5.5")
set_targetdir("bin")
-- project
set_project("humanseg")

-- set project version
set_version("1.0.0", {build = "%Y%m%d%H%M"})

-- add build modes
add_rules("mode.release", "mode.debug", "mode.profile", "mode.coverage")-- TODO, "mode.valgrind", "mode.asan", "mode.tsan", "mode.ubsan") -- for xmake v2.3.3

if is_plat("windows") then
    add_cxflags("-D_CRT_SECURE_NO_WARNINGS")
    includes("./3rd/win_crash_report")
end 




-- add target 
target("humanseg")
    -- make as a static library
    set_kind("static")
    
    -- set warning all as error
    set_warnings("all", "error")

    set_languages("c++11")
    set_optimize("fastest")

    -- disable some compiler errors
    add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=expansion-to-defined",  "-Wall", "-Wextra", "-Werror",  "-Wno-unused-function", "-Wno-deprecated-declarations", "-Wno-error=pointer-to-int-cast")
    add_mxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=expansion-to-defined")

    -- add include directories
    add_includedirs("./src", {public = true})
    add_includedirs("./3rd/onnxruntime-win-1.10.0/include/", {public = true})
    add_includedirs("./3rd/tflite/include/", {public = true})

    -- add link directories
    add_linkdirs("./3rd/onnxruntime-win-1.10.0/lib/$(arch)/")
    add_linkdirs("./3rd/tflite/lib/$(arch)/")

    add_files("src/*.cpp")
    add_linkdirs("./bin/")
    add_links("onnxruntime", "tensorflowlite_c.dll.if")
    add_packages("opencv")


target("test_img_seg")
    set_kind("binary")
        
    -- set warning all as error
    set_warnings("all", "error")

    set_languages("c++11")
    set_optimize("fastest")

    -- disable some compiler errors
    add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=expansion-to-defined",  "-Wall", "-Wextra", "-Werror",  "-Wno-unused-function", "-Wno-deprecated-declarations", "-Wno-error=pointer-to-int-cast")
    add_mxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=expansion-to-defined")


    add_files("test/test_img_seg.cpp")

    add_packages("opencv")
    add_deps("humanseg")


target("test_video_seg")
    set_kind("binary")
        
    -- set warning all as error
    set_warnings("all", "error")

    set_languages("c++11")
    set_optimize("fastest")

    -- disable some compiler errors
    add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=expansion-to-defined",  "-Wall", "-Wextra", "-Werror",  "-Wno-unused-function", "-Wno-deprecated-declarations", "-Wno-error=pointer-to-int-cast")
    add_mxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=expansion-to-defined")


    add_files("test/test_video_seg.cpp")

    add_packages("opencv")
    add_deps("humanseg")
    if is_plat("windows") then 
        add_deps("win_crash_report")
    end 